var t = getApp();

Page({
    data: {
        show1: !1,
        sort: "asc",
        category: {
            id: ""
        },
        name: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        titleInfo: "",
        commentList: [],
        categoryList: [],
        appointmentLang: {}
    },
    onLoad: function(t) {
        this.setData({
            appointmentLang: wx.getStorageSync("yz_basic_info").lang.appointment
        }), wx.setNavigationBarTitle({
            title: this.data.appointmentLang.project + "列表"
        }), this.init(), this.search(), this.getCategoryList();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    bind: function(t) {
        this.setData({
            name: t.detail.value
        });
    },
    search: function(a) {
        var e = this, o = t.getNetAddresss("plugin.appointment.frontend.project.get-list");
        t._getNetWork({
            url: o,
            data: {
                sort: this.data.sort,
                category_id: this.data.category.id,
                name: this.data.name,
                page: this.data.page
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    isLoadMore: !0,
                    total_page: a.data.last_page,
                    commentList: a.data.data
                }), e.data.total_page || e.setData({
                    total_page: 0
                })) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var e = this.data.page + 1;
            this.setData({
                page: e
            });
            var o = t.getNetAddresss("plugin.appointment.frontend.project.get-list");
            t._getNetWork({
                url: o,
                data: {
                    sort: this.data.sort,
                    category_id: this.data.category.id,
                    name: this.data.name,
                    page: this.data.page
                },
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        var o = e.data.data.concat(a.data.commentList);
                        a.setData({
                            commentList: o
                        });
                    } else {
                        wx.showToast({
                            title: e.msg,
                            icon: "none"
                        });
                        var s = a.data.page - 1;
                        a.setData({
                            page: s,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    evaluateBtn: function() {
        "asc" == this.data.sort ? this.setData({
            sort: "desc"
        }) : this.setData({
            sort: "asc"
        }), this.setData({
            page: 1,
            isLoadMore: !0,
            total_page: 0,
            show1: !1
        }), this.search();
    },
    goProjectDetails: function(t) {
        var a = t.currentTarget.dataset.id, e = JSON.stringify(wx.getStorageSync("address-point").point);
        wx.navigateTo({
            url: "/packageE/appointment/ProjectDetails/ProjectDetails?project_id=" + a + "&point=" + e
        });
    },
    selectionBtn: function(t) {
        var a = t.currentTarget.dataset.item;
        a.name ? this.setData({
            category: a
        }) : this.setData({
            category: {}
        }), this.setData({
            page: 1,
            isLoadMore: !0,
            total_page: 0,
            show1: !1
        }), this.search();
    },
    toIndex: function() {
        wx.navigateTo({
            url: "/packageE/appointment/appointment_index"
        });
    },
    toUrl: function() {
        var t = JSON.stringify(this.data.appointmentLang);
        wx.navigateTo({
            url: "/packageE/appointment/mine/mine?appointmentLang=" + t
        });
    },
    showClass: function() {
        this.setData({
            show1: !this.show1
        });
    },
    close: function() {
        this.setData({
            show1: !1
        });
    },
    enterSearch: function(t) {
        this.setData({
            page: 1,
            isLoadMore: !0,
            total_page: 0
        }), this.search();
    },
    getCategoryList: function() {
        var a = this, e = t.getNetAddresss("plugin.appointment.frontend.project-category.get-list");
        t._getNetWork({
            url: e,
            data: {},
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    categoryList: e.data
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    init: function() {
        this.setData({
            category: {},
            name: "",
            sort: "asc",
            show1: !1,
            page: 1,
            isLoadMore: !0,
            total_page: 0,
            commentList: []
        });
    }
});